#include <stdio.h>
#include <stdlib.h>
#include "list.h" // 请不要删除，否则检查不通过

struct rainy {
    LinkList val;
    struct rainy *pre;
};

struct rainy* newNode(LinkList val) {
    struct rainy* node = malloc(sizeof(struct rainy));
    node -> val = val;
    return node;
}

int lnk_search(LinkList L, int k, ElemType* p_ele) {
    struct rainy *node = newNode(L);
    for(LinkList tp = L -> next;tp;tp = tp -> next) {
        struct rainy* t = newNode(tp);
        t -> pre = node; node = t;
    }
    while(node && k--) node = node -> pre;
    if(!node) return 0;
    *p_ele = node -> val -> data;
    return 1;
}